import Mock from 'mockjs';

Mock.mock('http://localhost:8080/web/user/queryUserList','post', function(contentData){

    const conditions = {
        msg: '请求成功',
        resultCode: 200,
        result: {
            data: [{
                // id:'10001',
                neckName:'僵小鱼',
                partnerId: '230002',
                role: '管理员',
                status: '正常',
                address: '上海市普陀区',
                hot: "6", //热度
                charm: "200333", //魅力
                contribution: "5000" //贡献值
            },{
                // id:'10002',
                neckName:'范程程程程',
                partnerId: '13009',
                role: '管理员',
                status: '注销',
                address: '北京市东城区幸福大街32号',
                hot: "6", //热度
                charm: "200333", //魅力
                contribution: "5000" //贡献值
            },{
                // id:'10003',
                neckName:'TFToy',
                partnerId: '78752',
                role: '用户',
                status: '正常',
                address: '杭州市拱墅区',
                hot: "6", //热度
                charm: "200333", //魅力
                contribution: "206" //贡献值
            },{
                 // id:'10004',
                 neckName:'皮裤汪汪',
                 partnerId: '144332',
                 role: '管理员',
                 status: '注销',
                 address: '南京市玄武区兰园街道',
                 hot: "6", //热度
                 charm: "666", //魅力
                 contribution: "6300" //贡献值
            },{
                // "id":'10005',
                neckName:'hothothotdog',
                partnerId: '78752',
                role: '管理员',
                status: '正常',
                address: '深圳市宝安区',
                hot: "5", //热度
                charm: "25383", //魅力
                contribution: "6000" //贡献值
            },{
                // "id":'10007',
                neckName:'null',
                partnerId: '6677544',
                role: '管理员',
                status: '正常',
                address: '呼和浩特市玉泉区银河北街',
                hot: "5", //热度
                charm: "33222", //魅力
                contribution: "55555" //贡献值
            },{
                // "id":'10005',
                neckName:'拼夕夕',
                partnerId: '78752',
                role: '管理员',
                status: '正常',
                address: '浙江杭州人',
                hot: "6665", //热度
                charm: "2225383", //魅力
                contribution: "226000" //贡献值
            },{
                // "id":'10007',
                neckName:'猪猪侠闯天涯',
                partnerId: '6677544',
                role: '管理员',
                status: '正常',
                address: '成都市武侯区髙升桥路16号新世纪装饰广场',
                hot: "5", //热度
                charm: "33222", //魅力
                contribution: "55555" //贡献值
            }]
        }
    };

    let returnData = {
        msg: '请求成功',
        resultCode: 200,
        result: {
            data: []
        }
    };

    let searchDetail = JSON.parse(contentData.body).searchDetail;
    if(searchDetail){
        let dataList = [];
        conditions.result.data.map((p) => {
            if(p.neckName.indexOf(searchDetail) > -1 ||
                p.partnerId.indexOf(searchDetail) > -1 ||
                p.role.indexOf(searchDetail) > -1 ||
                p.status.indexOf(searchDetail) > -1 ||
                p.address.indexOf(searchDetail) > -1 ||
                p.hot.indexOf(searchDetail) > -1 || 
                p.charm.indexOf(searchDetail) > -1 || 
                p.contribution.indexOf(searchDetail) > -1){

                 dataList.push(p);
            }        
        });
        returnData.result.data = dataList;
    }else{
        returnData = conditions;
    }
    return returnData;
});